﻿using JmShared;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace JiveMessenger.Models
{

    public class JiveGroupMember:INotifyPropertyChanged, JiveMessenger.Models.IGroupMember
    {
        private string _username;
        public string Username
        {
            get { return _username; }
            set
            {
                if (_username != value)
                {
                    _username = value;
                    RaisePropertyChanged("Username");
                }
            }
        }


        private string _nickname;
        public string Nickname
        {
            get { return _nickname; }
            set
            {
                if (_nickname != value)
                {
                    _nickname = value;
                    RaisePropertyChanged("Nickname");
                }
            }
        }

        private GroupPrivilege _privilege;
        public GroupPrivilege Privilege
        {
            get { return _privilege; }
            set
            {
                if (_privilege != value)
                {
                    _privilege = value;
                    RaisePropertyChanged("Privilege");
                }
            }
        }


        public JiveGroupMember(string username, string nickname, GroupPrivilege privilege)
        {
            this.Username = username;
            this.Nickname = nickname;
            this.Privilege = privilege;
        }

        protected void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
        public event PropertyChangedEventHandler PropertyChanged;
    }
}
